<template>
  <Transition name="playmin">
    <div class="container11" v-show="!fullscreen && currentsong.id">
      <div class="left">
        <img @click="changefullscreen" :src="currentsong.pic" alt="" />
        <div class="text">
          <p>{{ currentsong.name }}</p>
          <p>{{ currentsong.singer }}</p>
        </div>
      </div>
      <div class="middle"></div>
      <div class="right">
        <span v-if="playing">
          <i class="icon-pause" @click="changeplaying"></i>
        </span>
        <span v-else>
          <i class="icon-play" @click="changeplaying"></i>
        </span>
        <span>
          <i class="icon-playlist" @click="changeplaylist"></i>
        </span>
      </div>
    </div>
  </Transition>
</template>

<script>
import { computed } from 'vue'
import { useStore } from 'vuex'
export default {
  name: 'Playmin',
  props: { currentsong: Object, fullscreen: Boolean },
  setup (props, { emit }) {
    const store = useStore()
    const playing = computed(() => store.state.playing)
    const playlist = computed(() => store.state.playlist)
    const changeplaying = () => {
      store.commit('changeplaying')
    }
    const changefullscreen = () => {
      store.commit('changefullscreen', true)
    }
    const changeplaylist = () => {
      emit('changeplaylist')
    }
    return {
      playing,
      changeplaying,
      changefullscreen,
      changeplaylist,
      playlist
    }
  }
}
</script>

<style scoped lang="scss">
.container11 {
  position: fixed;
  height: 60px;
  display: flex;
  bottom: 0;
  width: 100%;
  background: #333;
  .left {
    display: flex;
    align-items: center;
    width: 30%;
    margin-left: 20px;
    justify-content: space-around;
    img {
      height: 40px;
      width: 40px;
      border-radius: 50%;
    }
    & > .text {
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      p:nth-child(1) {
        font-size: 14px;
        color: white;
      }
      p:nth-child(2) {
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
        font-size: 12px;
        color: rgba(255, 255, 255, 0.3);
      }
    }
  }
  .right {
    position: absolute;
    right: 20px;
    color: rgba(255, 205, 49, 0.5);
    font-size: 32px;
    width: 25%;
    display: flex;
    justify-content: space-around;
    align-items: center;
    span {
      margin-top: 12px;
      width: 32px;
      height: 32px;
    }
  }
}
</style>
